import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;

class PermutationReader {
    public static List<Genome> readGenomes(String path) throws IOException {
        Scanner in = new Scanner(new File(path));
        List<Genome> genomes = new ArrayList<>();
        while (in.hasNext()) {
            String name = in.nextLine();
            List<Integer> blocks = new ArrayList<>();
            StringTokenizer tokenizer = new StringTokenizer(in.nextLine());
            while (tokenizer.hasMoreTokens()) {
                String s = tokenizer.nextToken();
                if (s.equals("$")) {
                    break;
                }
                blocks.add(Integer.parseInt(s));
            }
            Genome genome = new Genome(name, blocks);
            genomes.add(genome);
        }
        in.close();

        return genomes;
    }
}
